/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ps.server.componentes;

import java.util.Vector;
import javax.swing.AbstractListModel;
import javax.swing.ComboBoxModel;

/**
 *
 * @author Ricardo
 */
public class ComboBoxModelTextValue extends AbstractListModel implements ComboBoxModel {

   private Vector<comboClass> items;
     private Object seleccionado = null;

    public ComboBoxModelTextValue(Vector<comboClass> vt) {
        
        items= vt;
        seleccionado = items.get(0).getNombres();
        
    }     
    @Override
    public int getSize() {
        return items.size();
    }

    @Override
    public Object getElementAt(int index) {
        //String [][] robject= {{items[index][0],items[index][1].toString()}};
        //String  robject= items[index][1].toString();
        //return  robject;
        return items.get(index).getNombres();
    }

    @Override
    public void setSelectedItem(Object anItem) {
        for (int x=0;this.items.size()>x; x++){
                if (anItem==this.items.get(x)){
                    //selectedItem=this.items.get(x).getNombres();
                   seleccionado = this.items.get(x).getNombres();
                    break;
                }
            }
        
        seleccionado = (String)anItem;
        //fireContentsChanged(this, -1, -1);
    }

    @Override
    public Object getSelectedItem() {
        
        return seleccionado;
    }
    

   



   
}
